package test.doubleindex;

public class Solution3 {

    public int removeDuplicates(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        //在此处写入代码
        int j = 0;
        int count = 1;
        for (int i = 1; i< nums.length -1; i++) {
            if (nums[i] == nums[j]) {
                count ++;
            } else {
                count = 1;
            }
            if (count <= 2) {
                nums[++j] = nums[i];
            }
        }
        return j+1;

    }
}
